{template 'common/header'}
{if $op == 'display'}
<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site">
				<input type="hidden" name="a" value="entry">
				<input type="hidden" name="do" value="couponconsume">
				<input type="hidden" name="m" value="we7_coupon">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">卡券类型</label>
					<div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
						<a href="{php echo filter_url('type:0')}" class="btn btn-{if empty($_GPC['type'])}primary{else}default{/if}">全部</a>
						<a href="{php echo filter_url('type:1')}" class="btn btn-{if $_GPC['type'] == 1}primary{else}default{/if}">折扣券</a>
						<a href="{php echo filter_url('type:2')}" class="btn btn-{if $_GPC['type'] == 2}primary{else}default{/if}">代金券</a>
						{if COUPON_TYPE == WECHAT_COUPON}
						<a href="{php echo filter_url('type:3')}" class="btn btn-{if $_GPC['type'] == 3}primary{else}default{/if}">团购券</a>
						<a href="{php echo filter_url('type:4')}" class="btn btn-{if $_GPC['type'] == 4}primary{else}default{/if}">礼品券</a>
						<a href="{php echo filter_url('type:5')}" class="btn btn-{if $_GPC['type'] == 5}primary{else}default{/if}">优惠券</a>
						{/if}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
					<div class="col-sm-7 col-lg-8 col-md-8 col-xs-12 btn-group">
						<a class="btn btn-default {if $_GPC['status'] == '0'||$_GPC['status'] == ''}btn-primary{/if}" href="{php echo filter_url('status:0');}">不限</a>
						<a class="btn btn-default {if $_GPC['status'] == '1'}btn-primary{/if}" href="{php echo filter_url('status:1');}">未使用</a>
						<a class="btn btn-default {if $_GPC['status'] == '2'}btn-primary{/if}" href="{php echo filter_url('status:2');}">已失效</a>
						<a class="btn btn-default {if $_GPC['status'] == '3'}btn-primary{/if}" href="{php echo filter_url('status:3');}">已核销</a>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">code码</label>
					<div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
						<input class="form-control" name="code" placeholder="code码" type="text">
					</div>
				</div>
				{if $_GPC['status'] == '3' || ($_GPC['status'] == '' || empty($_GPC['status']))}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">核销员</label>
					<div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
						<select class="form-control" name="clerk_id">
							<option value="">不限</option>
							{loop $clerks $clerk}
							<option value="{$clerk['id']}" {if $_GPC['clerk_id'] == $clerk['id']}selected{/if}>{$clerk['name']}</option>
							{/loop}
						</select>
					</div>
				</div>
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">领取人</label>
					<div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
						<input class="form-control" name="nickname" placeholder="粉丝昵称" type="text" value="{$_GPC['nickname']}">
					</div>
					<div class="pull-right col-xs-12 col-sm-3 col-lg-2">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="panel panel-default">
		<div class="table-responsive panel-body">
			<table class="table table-hover">
				<thead class="navbar-inner">
				<tr>
					<th width="90">标题</th>
					<th width="90">领取方式</th>
					<th width="90">领取人</th>
					<th width="120">code码</th>
					<th width="60">状态</th>
					<th width="120">领取时间</th>
					{if $_GPC['status'] == '3' || ($_GPC['status'] == '' || empty($_GPC['status']))}
					<th width="120">使用时间</th>
					<th width="80">核销员</th>
					<th width="80">核销门店</th>
					{/if}
					<th style="width:150px; text-align:center;">操作</th>
				</tr>
				</thead>
				<tbody>
				{loop $list $row}
				<tr>
					<td>{$row['title']}</td>
					<td>
						{if $row['givebyfriend'] == 1}
						<span class="label label-danger" data-toggle="tooltip" data-placement="top" title="赠送人：">朋友赠送</span>
						{elseif !empty($row['grantmodule'])}
						<span class="label label-warning">模块发放</span>
						{else}
						<span class="label label-success">自己领取</span>
						{/if}
					</td>
					<td>
						{if $nicknames_info[$row['openid']]['nickname']}
						{$nicknames_info[$row['openid']]['nickname']}
						{else}
						{php echo cutstr($row['openid'], 8);}
						{/if}
					</td>
					<td>{$row['code']}</td>
					<td>
						{if $row['rstatus'] == 1}
						<span class="label label-success">未使用</span>
						{elseif $row['rstatus'] == 2}
						<span class="label label-warning">已失效</span>
						{elseif $row['rstatus'] == 3}
						<span class="label label-danger">已核销</span>
						{elseif $row['rstatus'] == 4}
						<span class="label label-default">已删除</span>
						{/if}
					</td>
					<td>
						{php echo date('Y-m-d H:i:s', $row['addtime']);}
					</td>
					{if $_GPC['status'] == '3' || ($_GPC['status'] == '' || empty($_GPC['status']))}
					<td>
						{if $row['usetime']}
						{php echo date('Y-m-d H:i:s', $row['usetime']);}
						{/if}
					</td>
					<td>{$row['clerk_name']}</td>
						<td>{$row['store_name']}</td>
					{/if}
					<td style="text-align:center;">
						{if $row['rstatus'] == 1 && $row['starttime'] <= $row['time'] && $row['endtime'] >= $row['time'] }
						<a href="javascript:;" onclick="util.ajaxshow('{php echo $this->createWebUrl('couponconsume', array('op' => 'consume', 'id' => $row['recid'], 'source' => $row['source']))}')" class="btn btn-default btn-sm" title="核销优惠券">核销</a>
						{/if}
						<a href="javascript:;" onclick="util.ajaxshow('{php echo $this->createWebUrl('couponconsume', array('op' => 'delete', 'id' => $row['recid'], 'source' => $row['source']))}')" class="btn btn-default btn-sm" title="删除兑换记录">删除</a>
					</td>
				</tr>
				{/loop}
				</tbody>
			</table>
		</div>
	</div>
	{$pager}
</div>
{/if}
{template 'common/footer'}